<template>
    <el-dialog title="提示" :visible.sync="show" width="30%">
        <p>确定删除此条数据吗？</p>
        <span slot="footer" class="dialog-footer">
            <el-button @click="show = false">取 消</el-button>
            <el-button type="primary" @click="deleteItem()">确 定</el-button>
        </span>
    </el-dialog>
</template>
<script>
    import api from '../../../api/api'
    import util  from '../../../common/util'

    export default {
        props: {
            data: null
        },
        data() {
            return {
                show:true,
            }
        },
        methods: {
            //添加更新
            deleteItem(){
                var fromData = this.data.formData;
                fromData.status = 0;
                let para = {
                    form:fromData,
                    tableName:this.data.tableName
                };
                let that = this;
                api.addOrEditSubmit(para).then((res) => {
                    if(res.ret==0){
                        that.$message({
                            type: 'success',
                            message: '删除成功！'
                        });
                        that.show = false;
                        that.$emit('refresh');
                    }
                }).catch(e => {
                    that.$message({
                        type: 'error',
                        message: '删除失败！'
                    });
                    that.show = false;
                });
            },
            close() {
                this.show = false;
            },
        },
        watch: {
            show(val) {
                if (!val) {
                    this.$emit('close');
                }
            }
        },
        created() {
        },
        mounted() {
        }
    }
</script>
